package org.mrzc.aware;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class AwareImpl implements BeanNameAware, ApplicationContextAware, IAware
{
    private ApplicationContext mApplication;

    private String mBeanName;

    Logger mLog = LoggerFactory.getLogger(AwareImpl.class);

    @Override
    public void setApplicationContext(ApplicationContext cApplicationContext) throws BeansException
    {
        mApplication = cApplicationContext;

        mLog.debug("ApplicationContext.classname---->{}", mApplication.getClass().getName());
    }

    @Override
    public void setBeanName(String cName)
    {
        mBeanName = cName;

        mLog.debug("BeanName={}", mBeanName);
    }

    @Override
    public void show()
    {
        mLog.debug("{}.show---->{}", this.getClass().getName(), mApplication.getBean(mBeanName));
    }

}
